// @flow
import { createAction, handleActions, type ActionType } from 'redux-actions';
import produce from 'immer';

/* ACTION TYPES */
const LOAD_ACCOUNTS = 'pay/LOAD_ACCOUNTS';
const SET_ACCOUNT = 'pay/SET_ACCOUNT';
const ADD_ACCOUNT = 'pay/ADD_ACCOUNT';
const DELETE_ACCOUNT = 'pay/DELETE_ACCOUNT';

/* ACTION PAYLOADS */
type Account = {
  pcode: string,
  code: string,
  name: string,
  accLevel: number,
  curency: Array<string>,
};
type Curency = {
  code: string,
  sig: string,
  name: string,
};
type AddAccountPayload = {
  account: Account,
  side: string,
};
/* EXPORTING ACTION CREATORS / ACTION CREATORS TYPES */
export interface PayActionCreators {
  loadAccounts(): any;
  setAccount(payload: Account): any;
  addAcount(payload: AddAccountPayload): any;
}

/* ACTION CREATORS */
export const actionCreators: PayActionCreators = {
  loadAccounts: createAction(LOAD_ACCOUNTS),
  setAccount: createAction(SET_ACCOUNT, (payload: Account) => payload),
  addAcount: createAction(ADD_ACCOUNT, (payload: AddAccountPayload) => payload),
};

/* ACTION FLOW TYPES */
type SetAccountAction = ActionType<typeof actionCreators.setAccount>;
type AddAccountAction = ActionType<typeof actionCreators.addAcount>;
/* State Types */

export type Pay = {
  Accounts: Array<Account>,
  Curencies: Array<Curency>,
  AccountForm: ?Account,
};

const initialState: Pay = {
  Accounts: [
    { pcode: 'ACC', code: 'ACC001', name: '资产类', accLevel: 1, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001001', name: '库存现金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001001', code: 'ACC001001001', name: '本人现金', accLevel: 3, curency: ['CNY'] },
    {
      pcode: 'ACC001001001',
      code: 'ACC001001001001',
      name: '本人现金',
      accLevel: 4,
      curency: ["CNY','RUB"],
    },
    { pcode: 'ACC001', code: 'ACC001002', name: '银行存款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001002', code: 'ACC001002001', name: '借记卡', accLevel: 3, curency: ['CNY'] },
    {
      pcode: 'ACC001002001',
      code: 'ACC001002001001.CNY',
      name: '中国工行85110',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC001002001',
      code: 'ACC001002001002.CNY',
      name: '中国银行13420',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC001002001',
      code: 'ACC001002001003.CNY',
      name: '昆仑银行80044',
      accLevel: 4,
      curency: ['CNY'],
    },
    { pcode: 'ACC001', code: 'ACC001003', name: '存放中央银行款项', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001011', name: '存放同业', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001015', name: '其它货币基金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001021', name: '结算备付金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001031', name: '存出保证金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001051', name: '拆出资金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001101', name: '交易性金融资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001111', name: '买入返售金融资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001121', name: '应收票据', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001122', name: '应收帐款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001123', name: '预付帐款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001131', name: '应收股利', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001132', name: '应收利息', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001211', name: '应收保护储金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001221', name: '应收代位追偿款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001222', name: '应收分保帐款', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC001',
      code: 'ACC001223',
      name: '应收分保未到期责任准备金',
      accLevel: 2,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC001',
      code: 'ACC001224',
      name: '应收分保保险责任准备金',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC001', code: 'ACC001231', name: '其它应收款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001241', name: '坏帐准备', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001251', name: '贴现资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001301', name: '贷款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001302', name: '贷款损失准备', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001311', name: '代理兑付证券', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001321', name: '代理业务资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001401', name: '材料采购', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001402', name: '在途物资', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001403', name: '原材料', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001404', name: '材料成本差异', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001406', name: '库存商品', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001407', name: '发出商品', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001410', name: '商品进销差价', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001411', name: '委托加工物资', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC001',
      code: 'ACC001412',
      name: '包装物及低值易耗品',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC001', code: 'ACC001421', name: '消耗性物物资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001431', name: '周转材料', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001441', name: '贵金属', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001442', name: '抵债资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001451', name: '损余物资', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001461', name: '存货跌价准备', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001501', name: '待摊费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001511', name: '独立帐户资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001521', name: '持有至到期投资', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC001',
      code: 'ACC001522',
      name: '持有至到期投资减值准备',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC001', code: 'ACC001523', name: '可供出售金融资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001524', name: '长期股权投资', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC001',
      code: 'ACC001525',
      name: '长期股权投资减值准备',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC001', code: 'ACC001526', name: '投资性房地产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001531', name: '长期应收款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001541', name: '未实现融资收益', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001551', name: '存出资本保证金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001601', name: '固定资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001602', name: '累计折旧', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001603', name: '固定资产减值准备', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001604', name: '在建工程', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001605', name: '工程物资', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001606', name: '固定资产清理', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001611', name: '融资租赁资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001612', name: '未担保余值', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001621', name: '生产性生物资产', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC001',
      code: 'ACC001622',
      name: '生产性生物资产累计折旧',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC001', code: 'ACC001623', name: '公益性生物资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001631', name: '油气资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001632', name: '累计折耗', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001701', name: '无形资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001702', name: '累计摊销', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001703', name: '无形资产减值准备', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001711', name: '商誉', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001801', name: '长期待摊费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001811', name: '递延所得资产', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC001', code: 'ACC001901', name: '待处理财产损益', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC', code: 'ACC002', name: '负债类', accLevel: 1, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002001', name: '短期借款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002002', name: '存入保证金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002003', name: '拆入资金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002004', name: '向中央银行借款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002011', name: '同业存放', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002012', name: '吸收存款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002021', name: '贴现负债', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002101', name: '交易性金融负债', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC002',
      code: 'ACC002111',
      name: '专出回购金融资产款',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC002', code: 'ACC002201', name: '应付票据', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002202', name: '应付帐款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002205', name: '预收帐款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002211', name: '应付职工薪酬', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002221', name: '应交税费', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002231', name: '应付股利', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002232', name: '应付利息', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002241', name: '其他应付款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002241', code: 'ACC002241001', name: '信用卡', accLevel: 3, curency: ['CNY'] },
    {
      pcode: 'ACC002241001',
      code: 'ACC002241001001.CNY',
      name: '中国银行银联33775',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC002241001',
      code: 'ACC002241001002.CNY',
      name: '中国银行VISA55974',
      accLevel: 4,
      curency: ['CNY'],
    },
    { pcode: 'ACC002241', code: 'ACC002241002', name: '福利卡', accLevel: 3, curency: ['CNY'] },
    {
      pcode: 'ACC002241002',
      code: 'ACC002241002001.CNY',
      name: '克拉玛依和家乐13270',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC002241002',
      code: 'ACC002241002002.CNY',
      name: '克拉玛依和家乐90640',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC002241002',
      code: 'ACC002241002003.CNY',
      name: '克拉玛依和家乐41343',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC002241002',
      code: 'ACC002241002004.CNY',
      name: '克拉玛依美廉21188',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC002241002',
      code: 'ACC002241002005.CNY',
      name: '克拉玛依葡萄树65661',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC002241002',
      code: 'ACC002241002006.CNY',
      name: '克拉玛依汇嘉481870',
      accLevel: 4,
      curency: ['CNY'],
    },
    { pcode: 'ACC002241', code: 'ACC002241003', name: '预付交通卡', accLevel: 3, curency: ['CNY'] },
    {
      pcode: 'ACC002241003',
      code: 'ACC002241003001.CNY',
      name: '克拉玛依公交卡01143499',
      accLevel: 4,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC002241003',
      code: 'ACC002241003002.CNY',
      name: '成都天府通20638582',
      accLevel: 4,
      curency: ['CNY'],
    },
    { pcode: 'ACC002241', code: 'ACC002241004', name: '预付餐卡', accLevel: 3, curency: ['CNY'] },
    {
      pcode: 'ACC002241004',
      code: 'ACC002241004001.CNY',
      name: '太阳城快餐卡0440',
      accLevel: 4,
      curency: ['CNY'],
    },
    { pcode: 'ACC002', code: 'ACC002251', name: '应付保户红利', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002261', name: '应付分保帐款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002311', name: '代理买卖证券款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002312', name: '代理承销证券款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002313', name: '代理兑付证券款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002314', name: '代理业务负债', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002401', name: '预提费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002411', name: '预计负债', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002501', name: '递延收益', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002601', name: '长期借款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002602', name: '长期债券', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002701', name: '到期责任准备金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002702', name: '保险责任准备金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002711', name: '保户储金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002721', name: '独立帐户负债', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002801', name: '长期应付款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002802', name: '未确认融资费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002811', name: '专项应付款', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC002', code: 'ACC002901', name: '递延所得税负债', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC', code: 'ACC003', name: '共同类', accLevel: 1, curency: ['CNY'] },
    { pcode: 'ACC003', code: 'ACC003001', name: '清算资金往来', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC003', code: 'ACC003002', name: '外汇买卖', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC003', code: 'ACC003101', name: '衍生工具', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC003', code: 'ACC003201', name: '套期工具', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC003', code: 'ACC003202', name: '被套期项目', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC', code: 'ACC004', name: '所有者权益类', accLevel: 1, curency: ['CNY'] },
    { pcode: 'ACC004', code: 'ACC004001', name: '实收资本', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC004', code: 'ACC004002', name: '资本公积', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC004', code: 'ACC004101', name: '盈余公积', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC004', code: 'ACC004102', name: '一般风险准备', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC004', code: 'ACC004103', name: '套期工具', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC004', code: 'ACC004104', name: '利润分配', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC004', code: 'ACC004201', name: '库存股', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC', code: 'ACC005', name: '成本类', accLevel: 1, curency: ['CNY'] },
    { pcode: 'ACC005', code: 'ACC005001', name: '生产成本', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC005', code: 'ACC005101', name: '制造费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC005', code: 'ACC005201', name: '劳务成本', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC005', code: 'ACC005301', name: '研发支出', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC005', code: 'ACC005401', name: '工程施工', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC005', code: 'ACC005402', name: '工程结算', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC005', code: 'ACC005403', name: '机械作业', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC', code: 'ACC006', name: '损益类', accLevel: 1, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006001', name: '主营业务收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006011', name: '利息收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006021', name: '手续费收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006031', name: '保费收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006032', name: '分保费收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006041', name: '租赁收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006051', name: '其他业务收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006061', name: '汇兑损益', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006101', name: '公允价值变动损益', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006111', name: '投资收益', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC006',
      code: 'ACC006201',
      name: '摊回保险责任准备金',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC006', code: 'ACC006202', name: '摊回赔付支出', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006203', name: '摊回分保费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006301', name: '营业外收入', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006401', name: '主营业务成本', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006402', name: '其它业务成本', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006405', name: '营业税金及附加', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006411', name: '利息支出', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006421', name: '手续费支出', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC006',
      code: 'ACC006501',
      name: '提取未到期责任准备金',
      accLevel: 2,
      curency: ['CNY'],
    },
    { pcode: 'ACC006', code: 'ACC006502', name: '撮保险责任准备金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006511', name: '赔付支出', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006521', name: '保户红利支出', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006531', name: '退保金', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006541', name: '分出保费', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006542', name: '分保费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006601', name: '销售费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006602', name: '管理费用', accLevel: 2, curency: ['CNY'] },
    {
      pcode: 'ACC006602',
      code: 'ACC006602001',
      name: '娱乐、玩乐费用',
      accLevel: 3,
      curency: ['CNY'],
    },
    {
      pcode: 'ACC006602001',
      code: 'ACC006602001001.CNY',
      name: '旅游费用',
      accLevel: 4,
      curency: ["CNY','RUB"],
    },
    { pcode: 'ACC006', code: 'ACC006603', name: '财务费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006604', name: '勘探费用', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006701', name: '资产减值损失', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006711', name: '营业外支出', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006801', name: '所得税', accLevel: 2, curency: ['CNY'] },
    { pcode: 'ACC006', code: 'ACC006901', name: '以前年度损益调整', accLevel: 2, curency: ['CNY'] },
  ],
  Curencies: [],
  AccountForm: null,
};

const reducers = handleActions(
  {
    [SET_ACCOUNT]: (state, action: SetAccountAction) => state,
    [ADD_ACCOUNT]: (state, action: AddAccountAction) => {
      return produce(state, (draft) => {
        if (!action || !draft) return;
        draft.value = action.payload.account;
      });
    },
    //   [INSERT]: (state, action: InsertAction) => {
    //     return produce(state, (draft) => {
    //       if (!action || !draft) return;
    //       draft.todos.push({ ...action.payload, done: false });
    //     });
    //   },
    //   [CHANGE]: (state, action: ChangeAction) => {
    //     return produce(state, (draft) => {
    //       if (!action || !draft) return;
    //       draft.text = action.payload;
    //     });
    //   },
  },
  initialState,
);
const effects = function* rootSaga() {
  yield console.log('hello');
};
export default { reducers, effects };
